package cn.sytton.taffe.monitor.model;

import cn.hutool.core.util.NumberUtil;
import io.swagger.v3.oas.annotations.media.Schema;

/**
 * cpu信息
 *
 * @author skyrock
 */
@Schema(description = "CPU信息")
public class Cpu {
    /**
     * 核心数
     */
    @Schema(description = "核心数")
    private int num;

    /**
     * CPU总的使用率
     */
    @Schema(description = "CPU总的使用率")
    private double total;

    /**
     * CPU系统使用率
     */
    @Schema(description = "CPU系统使用率")
    private double sys;

    /**
     * CPU用户使用率
     */
    @Schema(description = "CPU用户使用率")
    private double used;

    /**
     * CPU当前等待率
     */
    @Schema(description = "CPU当前等待率")
    private double wait;

    /**
     * CPU当前空闲率
     */
    @Schema(description = "CPU当前空闲率")
    private double free;

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    public double getTotal() {
        return NumberUtil.round(NumberUtil.mul(total, 100), 2).doubleValue();
    }

    public void setTotal(double total) {
        this.total = total;
    }

    public double getSys() {
        return NumberUtil.mul(NumberUtil.div(sys, total, 4), 100);
    }

    public void setSys(double sys) {
        this.sys = sys;
    }

    public double getUsed() {
        return NumberUtil.mul(NumberUtil.div(used, total, 4), 100);
    }

    public void setUsed(double used) {
        this.used = used;
    }

    public double getWait() {
        return NumberUtil.mul(NumberUtil.div(wait, total, 4), 100);
    }

    public void setWait(double wait) {
        this.wait = wait;
    }

    public double getFree() {
        return NumberUtil.mul(NumberUtil.div(free, total, 4), 100);
    }

    public void setFree(double free) {
        this.free = free;
    }
}
